<?php

class Ext_Avatar_Save_Adapter
{
    protected $_adapter;

    public function __construct()
    {
        $config = Ext_Config::getInstance()->getConfig('image');

        $classname = "Ext_Avatar_Save_Adapter_".ucfirst($config->storage->adapter);
        if(!class_exists( $classname ))
        {
            require_once 'Ext/Avatar/Save/Exception.php';
            throw new Ext_Avatar_Save_Exception("Avatar save adapter '".$classname."' is not exists.");
        }
        
        $this->_adapter = new $classname();
    }
    
    public function save($file)
    {
        return $this->_adapter->save($file);
    }
}
